//
//  GetDeviceMessageTool.m
//
//
//  Created by gynjobs on 2017/8/15.
//  Copyright © 2017年 gynjobs. All rights reserved.
//

#import "GetDeviceMessageTool.h"
#import "sys/utsname.h"
@implementation GetDeviceMessageTool
+ (NSString * ) DeviceUUID{
    return [[[UIDevice currentDevice] identifierForVendor] UUIDString];
}

+ (NSString * ) DeviceUserName{
    
    return [[UIDevice currentDevice] name];
}

+ (NSString * ) DeviceSystemName{
    
    return [[UIDevice currentDevice] systemName];
}

+ (NSString * ) DeviceVersion{
    
    return [[UIDevice currentDevice] systemVersion];
}

+ (NSString * ) DeviceModel{
    
    return [[UIDevice currentDevice] model];
}

+ (NSString * ) DeviceLocalModel{
    
    return [[UIDevice currentDevice] localizedModel];
}


+ (NSString * ) AppName{
    
    NSDictionary * infoDic = [[NSBundle mainBundle] infoDictionary];
    return [infoDic objectForKey:@"CFBundleDisplayName"];
}

+ (NSString * ) AppVersion{
    
    NSDictionary * infoDic = [[NSBundle mainBundle] infoDictionary];
    return [infoDic objectForKey:@"CFBundleShortVersionString"];
}

+ (NSString * ) AppVersionNum{
    
    NSDictionary * infoDic = [[NSBundle mainBundle] infoDictionary];
    return [infoDic objectForKey:@"CFBundleShortVersionString"];
}

+ (NSString * ) AppInfo{
    
    return [[[NSBundle mainBundle] infoDictionary] description];
    
}

+ (NSString *) DeviceModelName{
    // 需要#import "sys/utsname.h"
    struct utsname systemInfo;
    uname(&systemInfo);
    NSString *deviceString = [NSString stringWithCString:systemInfo.machine encoding:NSUTF8StringEncoding];
    
    //iPhone
    if ([deviceString isEqualToString:@"iPhone4,1"])    return @"iPhone 4S";
    if ([deviceString isEqualToString:@"iPhone5,1"])    return @"iPhone 5";
    if ([deviceString isEqualToString:@"iPhone5,2"])    return @"iPhone 5";
    if ([deviceString isEqualToString:@"iPhone5,3"])    return @"iPhone 5C";
    if ([deviceString isEqualToString:@"iPhone5,4"])    return @"iPhone 5C";
    if ([deviceString isEqualToString:@"iPhone6,1"])    return @"iPhone 5S";
    if ([deviceString isEqualToString:@"iPhone6,2"])    return @"iPhone 5S";
    if ([deviceString isEqualToString:@"iPhone7,1"])    return @"iPhone 6 Plus";
    if ([deviceString isEqualToString:@"iPhone7,2"])    return @"iPhone 6";
    if ([deviceString isEqualToString:@"iPhone8,1"])    return @"iPhone 6s";
    if ([deviceString isEqualToString:@"iPhone8,2"])    return @"iPhone 6s Plus";
    if ([deviceString isEqualToString:@"i386"])         return @"Simulator";
    if ([deviceString isEqualToString:@"x86_64"])       return @"Simulator";
    
    return nil;
}
@end
